-----------------------------------------------------------------------------------------
-----------------------------------PopUp Facebook -------------------------------------------
-----------------------------------------------------------------------------------------
module(..., package.seeall)

function new(onEvent,onReplayEvent)
	local ui = require("ui")
	local wEasing = require "wEasing"
	local gui = require "popup.popupPauseGui".new()
	local storyboard = require( "storyboard" )
	local popupPauseGroup = display.newGroup()
	local bg = display.newImageRect(popupPauseGroup, gui.bg.fn, gui.bg.w, gui.bg.h)
		bg.x = gui.bg.x
		bg.y = gui.bg.y
	local bgChan = display.newRect(popupPauseGroup, 0,0, display.contentWidth, display.contentHeight)
		bgChan:setFillColor (0,50)
		bgChan:addEventListener("tap",function()return true end)
		bgChan:addEventListener("touch",function()return true end)
	
	local btnHome = ui.newButton({ 
									defaultSrc = gui.btnHome.fn,
									overSrc = gui.btnHome.fn,
									defaultX = gui.btnHome.w,
									defaultY = gui.btnHome.h,
									overX = gui.btnHome.w,
									overY = gui.btnHome.h,
									x = gui.btnHome.x,
									y = gui.btnHome.y,
									overAlpha = gui.btnHome.overAlpha,
									overScale = gui.btnHome.overScale,
									onRelease = function()
													transition.to(popupPauseGroup,{time = 100,alpha = 1, x = 0, y = -600, transition = wEasing.easeOutElastic,
														onStart = function()
															popupPauseGroup:removeSelf()
														end })
													storyboard.gotoScene("Home.Home", "fade",100 )
													----------tro ve man hinh Home-------------------------
												end
									})
		popupPauseGroup:insert(btnHome)
	local btnResume = ui.newButton({ 
									defaultSrc = gui.btnResume.fn,
									overSrc = gui.btnResume.fn,
									defaultX = gui.btnResume.w,
									defaultY = gui.btnResume.h,
									overX = gui.btnResume.w,
									overY = gui.btnResume.h,
									x = gui.btnResume.x,
									y = gui.btnResume.y,
									overAlpha = gui.btnResume.overAlpha,
									overScale = gui.btnResume.overScale,
									onRelease = function()
													transition.to(popupPauseGroup,{time = 100,alpha = 1, x = 0, y = -500, transition = wEasing.easeOutElastic,
													onStart = function()
														popupPauseGroup:removeSelf()
													end
													})
													onEvent()
													------------------choi tiep ----------------------------------
												end
									})
		popupPauseGroup:insert(btnResume)
	local btnReplay = ui.newButton({ 
									defaultSrc = gui.btnReplay.fn,
									overSrc = gui.btnReplay.fn,
									defaultX = gui.btnReplay.w,
									defaultY = gui.btnReplay.h,
									overX = gui.btnReplay.w,
									overY = gui.btnReplay.h,
									x = gui.btnReplay.x,
									y = gui.btnReplay.y,
									overAlpha = gui.btnReplay.overAlpha,
									overScale = gui.btnReplay.overScale,
									onRelease = function()
													transition.to(popupPauseGroup,{time = 100,alpha = 1, x = 0, y = -500, transition = wEasing.easeOutElastic,
													onStart = function()
														popupPauseGroup:removeSelf()
													end
													})
													onReplayEvent()
													--------------------choi lai tu dau----------------------------
												end
									})
		popupPauseGroup:insert(btnReplay)
	local btnExit = ui.newButton({ 
									defaultSrc = gui.btnExit.fn,
									overSrc = gui.btnExit.fn,
									defaultX = gui.btnExit.w,
									defaultY = gui.btnExit.h,
									overX = gui.btnExit.w,
									overY = gui.btnExit.h,
									x = gui.btnExit.x,
									y = gui.btnExit.y,
									overAlpha = gui.btnExit.overAlpha,
									overScale = gui.btnExit.overScale,
									onRelease = function()
													transition.to(popupPauseGroup,{time = 100,alpha = 1, x = 0, y = -500, transition = wEasing.easeOutElastic,
													onStart = function()
														popupPauseGroup:removeSefl()
													end
													})
													onReplayEvent()
													--------------------choi lai tu dau----------------------------
												end
									})
		popupPauseGroup:insert(btnExit)
	return popupPauseGroup
end
